package monitor;

import machine.AgriculturalMachine;

import java.util.ArrayList;
import java.util.List;

public class EnvironmentMonitor {  // 被观察者（环境监测模块）
    private final List<AgriculturalMachine> observers = new ArrayList<>();

    public void addObserver(AgriculturalMachine observer) {
        observers.add(observer);
    }

    public void notifyObservers(String envInfo) {
        System.out.println("\n[环境监测] 新数据: " + envInfo);
        observers.forEach(observer -> observer.executeTask("响应环境变化: " + envInfo));
    }
}
